//课程按钮点击事件
$("body").on('click', "button", function() {
	var str = $(this).text().trim();
	var html = "";
	switch(str) {
		case "增加次数":
		case "立即购买":
			html += "<ul class='am-avg-sm-1 am-text-left font14'>";
			html += "<li>请选择你要购买的玩沙项目的次数</li>";
			html += "<li><ul class='am-avg-sm-5 dis-flex  paly_csul'>";
			html += "<li>1次</li><li>5次</li><li>10次</li><li>20次</li><li>50次</li>";
			html += "</ul></li>";
			html += "<li class='am-text-center am-padding-top-sm'>是否消耗(200个立方币)购买5次?</li>";
			html += "</ul>";
			$('#class_model .am-modal-hd').html("购买次数");
			$("#class_model .am-modal-bd").html(html);
			$('#class_model').modal({
				relatedTarget: this,
				closeViaDimmer: false,
				onConfirm: function(options) {
					$("#class_model").removeData('amui.modal');
					bespeaks();
				}
			});
			break;
		case "续玩一次":
			html += "<ul class='am-avg-sm-1 am-text-left font14'>";
			html += "<li class='am-text-center am-padding-top-sm font16'>是否消耗(200个立方币)续玩一次?</li>";
			html += "</ul>";
			$('#class_model .am-modal-hd').html("购买次数");
			$("#class_model .am-modal-bd").html(html);
			$('#class_model').modal({
				relatedTarget: this,
				closeViaDimmer: false,
				onConfirm: function(options) {
					$("#class_model").removeData('amui.modal');
					bespeaks();
				}
			});
			break;
		default:
			break;

	}
});
var clearFlag = 0;
var count = 3; //设置3秒后自动消失
//立即预约
function bespeaks() {
	$("#alert_model .am-modal-bd").html("");
	var i = 1;
	if(i == 1) {
		$("#alert_model .am-modal-bd").html("购买成功！<span></span>");
		$('#alert_model').modal("open");
		count = 3;
		clearFlag = self.setInterval("autoClose()", 1000); //每过一秒调用一次autoClose方法
	} else {
		$('#gmsb_model .am-modal-hd').html("购买失败!");
		var html = "";
		html += "<ul class='am-avg-sm-1 am-text-center font14'>";
		/*html += "<li>购买失败！<li>"*/
		html += "<li>余额不足，是否立即去充值?<li>"
		html += "</ul>";
		$("#gmsb_model .am-modal-bd").html(html);
		$('#gmsb_model').modal({
			relatedTarget: this,
			closeViaDimmer: false,
			onConfirm: function(options) {
				$("#gmsb_model").removeData('amui.modal');
				location.href = "recharge.html"; //去充值页面
			}
		});
	}
}